
package infbmobile.comunicaciones;

import infbmobile.pantallas.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Alert;


public class GrabadoraMovil implements Runnable{

   byte[]audio;
   private String dni;

    public GrabadoraMovil( byte[] audio,String dni){
      
        this.audio=audio;
        this.dni=dni;
        
    }

    public void run() {
 
        HttpConnection conexion = null;
       
        OutputStream salida= null;

        try {
        String miUrl = "http://localhost:8080/GestionHospitalaria/Audio";
        conexion = (HttpConnection) Connector.open(miUrl);
        conexion.setRequestProperty("Content-Language", "es-ES");
        conexion.setRequestProperty("Content-Type","audio/x-wav");
        conexion.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
        conexion.setRequestProperty("Connection", "close");

        conexion.setRequestMethod(HttpConnection.GET);
 

        salida = conexion.openOutputStream();

        DataOutputStream out = new DataOutputStream(salida);
        
        out.writeInt( audio.length);
       
        out.write(audio, 0, audio.length);
        out.writeUTF(dni);


        out.flush();
        out.close();
        salida.close();
       
        conexion.close();


        } catch (IOException ex) {
             System.err.println("algo va mal ");
        } finally {

        }
    }

   

   
}
